﻿using System;
using System.ComponentModel;
using SSS.AlphaNN.Components;

namespace SSS.AlphaNN.Logic
{
    /// <summary>
    /// Структура тип веса
    /// </summary>
    public struct TypeWeight
    {
        /// <summary>
        /// Значение
        /// </summary>
         [DefaultValue(0)]
        public double Value
        {
            get;
            set;
        }

        /// <summary>
        /// Есть ли вес
        /// </summary>
        [DefaultValue(false)]
        public bool ValueSet
        {
            get;
            set;
        }

        public Link LinkDestation
        {
            get; set;
        }
        
        public static TypeWeight operator+ (TypeWeight a, TypeWeight b)
        {
            
            TypeWeight c=new TypeWeight();
            
            c.ValueSet = a.ValueSet&&b.ValueSet;
            if (c.ValueSet)
                c.Value = a.Value + b.Value;
            return c;
        }

        public static TypeWeight operator -(TypeWeight a, TypeWeight b)
        {
            TypeWeight c = new TypeWeight();
            c.ValueSet = a.ValueSet && b.ValueSet;
            if (c.ValueSet)
                c.Value = a.Value - b.Value;
            return c;
        }

        public static TypeWeight operator *(TypeWeight a, TypeWeight b)
        {
            TypeWeight c = new TypeWeight();
            c.ValueSet = a.ValueSet && b.ValueSet;
            if (c.ValueSet)
                c.Value = a.Value * b.Value;
            return c;
        }

        public static TypeWeight operator /(TypeWeight a, TypeWeight b)
        {
            TypeWeight c = new TypeWeight();
            c.ValueSet = a.ValueSet && b.ValueSet;
            if (c.ValueSet)
                c.Value = a.Value / b.Value;
            return c;
        }

        public static bool operator ==(TypeWeight a, TypeWeight b)
        {
            bool c =false;
            c = a.ValueSet && b.ValueSet;
            if (c)
                c = a.Value == b.Value;
            return c;
        }

        public static bool operator !=(TypeWeight a, TypeWeight b)
        {
            return !(a == b);
        }

        public static bool operator > (TypeWeight a, TypeWeight b)
        {
            bool c = false;
            c = a.ValueSet && b.ValueSet;
            if (c)
                c = a.Value > b.Value;
            return c;
        }

        public static bool operator <(TypeWeight a, TypeWeight b)
        {
            return !(a>b);
        }

        public static TypeWeight operator +(TypeWeight a, double b)
        {
            TypeWeight b1=new TypeWeight(){Value = b, ValueSet = true};
            return a + b1;
        }

        public static TypeWeight operator -(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            
            return a-b1;
        }
        public static TypeWeight operator *(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a*b1;
        }

        public static TypeWeight operator /(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a / b1;
        }

        public static bool operator ==(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a == b1;
        }

        public static bool operator !=(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a != b1;
        }

        public static bool operator >(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a > b1;
        }

        public static bool operator <(TypeWeight a, double b)
        {
            TypeWeight b1 = new TypeWeight() { Value = b, ValueSet = true };
            return a < b1;
        }

        public static TypeWeight operator +(double a, TypeWeight b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };
           
            return a1+b;
        }

        public static TypeWeight operator -(double a,TypeWeight  b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 - b;
        }
        public static TypeWeight operator *(double a,TypeWeight  b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 * b;
        }

        public static TypeWeight operator /(double a, TypeWeight b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 / b;
        }

        public static bool operator ==(double a, TypeWeight b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 == b;
        }

        public static bool operator !=(double a, TypeWeight b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 != b;
        }

        public static bool operator >(double a, TypeWeight b)
        {
            TypeWeight a1 = new TypeWeight() { Value = a, ValueSet = true };

            return a1 > b;
        }

        public static bool operator <(double a, TypeWeight b)
        {
            return !(a > b);
        }

        
    }

    
}
